package erz.printing.police;

import android.content.Intent;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class AnjianActivity extends BaseActivity implements View.OnClickListener {

    private View bianRenEntry;
    private View shouchaEntry;
    private View zhengjuEntry;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_anjian);

        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);

        initView();
        initRightDutyPrint();
    }

    @Override
    public boolean onSupportNavigateUp() {
        finish();
        return true;
    }

    private void initView() {
        bianRenEntry = findViewById(R.id.bianren_entry);
        shouchaEntry = findViewById(R.id.shoucha_entry);
        zhengjuEntry = findViewById(R.id.zhengju_entry);

        bianRenEntry.setOnClickListener(this);
        shouchaEntry.setOnClickListener(this);
        zhengjuEntry.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.bianren_entry) {
            Intent intent = new Intent(this, PrintPhotoActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("checkTitle", "现场辨认");
            bundle.putString("docTemplateNotice", "pdf/辨认现场笔录.pdf");
            bundle.putString("noticeName", "辨认笔录");
            bundle.putString("title", "现场辨认");
            //bundle.putBoolean("printTitle", true);
            intent.putExtras(bundle);
            startActivity(intent);
        }
        else if (view.getId() == R.id.shoucha_entry) {
            Intent intent = new Intent(this, PrintPhotoActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("checkTitle", "现场检查");
            bundle.putString("docTemplateNotice", "pdf/检查笔录.pdf");
            bundle.putString("noticeName", "检查笔录");
            bundle.putString("title", "现场检查");
            //bundle.putBoolean("printTitle", true);
            intent.putExtras(bundle);
            startActivity(intent);
        }
        else if (view.getId() == R.id.zhengju_entry) {
            Intent intent = new Intent(this, PrintPhotoActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("checkTitle", "接受证据");
            bundle.putString("docTemplateNotice", "pdf/调取证据清单.pdf");
            bundle.putString("noticeName", "接受证据清单");
            bundle.putString("title", "接受证据");
            //bundle.putBoolean("printTitle", true);
            intent.putExtras(bundle);
            startActivity(intent);
        }
    }

    private void startDocumentActivity(String docTemplate, String title) {
        Intent newIntent = new Intent(this, DocumentActivity.class);
        Bundle newBundle = new Bundle();

        newBundle.putString("docTemplate", docTemplate);
        newBundle.putString("title", title);

        newIntent.putExtras(newBundle);
        startActivity(newIntent);
    }

    private void initRightDutyPrint() {
        findViewById(R.id.bei_hai_ren).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startDocumentActivity("pdf/被害人权利义务告知书.pdf", "被害人权利义务告知书");
            }
        });
        findViewById(R.id.bei_hai_ren_su_song).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startDocumentActivity("pdf/被害人诉讼权利义务告知书.pdf", "被害人诉讼权利义务告知书");
            }
        });
        findViewById(R.id.xiang_zheng_an_jian).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startDocumentActivity("pdf/行政案件权利义务告知书.pdf", "行政案件权利义务告知书");
            }
        });
        findViewById(R.id.zheng_ren_su_song).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startDocumentActivity("pdf/证人诉讼权利义务告知书.pdf", "证人诉讼权利义务告知书");
            }
        });
    }
}
